package com.csust.travel.entity;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Comment {
    private Integer user_id;
    private Integer reviewer;
    private Integer id;
    private Integer order_id;
    private String book_name;
    private String transaction_date;
    private String comment_time;
    private Integer rate;
    private String content;
    private String book_img;
    private List<String> imgList;
    private String  img_list;
    private  Integer hasRecommented;

    // Getters and Setters


    public Integer getUser_id() {
        return user_id;
    }

    public void setUser_id(Integer user_id) {
        this.user_id = user_id;
    }

    public Integer getReviewer() {
        return reviewer;
    }

    public void setReviewer(Integer reviewer) {
        this.reviewer = reviewer;
    }

    public Integer getHasRecommented() {
        return hasRecommented;
    }

    public void setHasRecommented(Integer hasRecommented) {
        this.hasRecommented = hasRecommented;
    }

    public Integer getOrder_id() {
        return order_id;
    }

    public void setOrder_id(Integer order_id) {
        this.order_id = order_id;
    }

    public String getImg_list() {
        return img_list;
    }

    public void setImg_list(String img_list) {
        this.img_list = img_list;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBook_name() {
        return book_name;
    }

    public void setBook_name(String book_name) {
        this.book_name = book_name;
    }

    public String getTransaction_date() {
        return transaction_date;
    }

    public void setTransaction_date(String transaction_date) {
        this.transaction_date = transaction_date;
    }

    public String getComment_time() {
        return comment_time;
    }

    public void setComment_time(String comment_time) {
        this.comment_time = comment_time;
    }

    public Integer getRate() {
        return rate;
    }

    public void setRate(Integer rate) {
        this.rate = rate;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getBook_img() {
        return book_img;
    }

    public void setBook_img(String book_img) {
        this.book_img = book_img;
    }

    public List<String> getImgList() {
        return imgList;
    }

    public void setImgList(List<String> imgList) {
        this.imgList = imgList;
    }

    // 将逗号分隔的字符串转换为列表
    public void setImgListFromDb(String imgListStr) {
        if (imgListStr != null && !imgListStr.isEmpty()) {
            this.imgList = Arrays.asList(imgListStr.split(","));
        } else {
            this.imgList = Collections.emptyList();
        }
    }

    // 将列表转换为逗号分隔的字符串
    public String getImgListForDb() {
        if (imgList != null && !imgList.isEmpty()) {
            return String.join(",", imgList);
        } else {
            return "";
        }
    }

    @Override
    public String toString() {
        return "Comment{" +
                "id=" + id +
                ", order_id=" + order_id +
                ", book_name='" + book_name + '\'' +
                ", transaction_date='" + transaction_date + '\'' +
                ", comment_time='" + comment_time + '\'' +
                ", rate=" + rate +
                ", content='" + content + '\'' +
                ", book_img='" + book_img + '\'' +
                ", imgList=" + imgList +
                ", img_list='" + img_list + '\'' +
                '}';
    }
}
